package com.jinlia.show.modules.base.wxapp.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
import com.jinlia.show.common.core.entity.BaseEntity;
import com.jinlia.show.modules.base.config.DynamicSchemaConfig;
import com.jinlia.show.modules.base.constant.OrderPayStatusEnum;
import com.jinlia.show.modules.base.constant.PayForTypeEnum;
import com.jinlia.show.modules.base.constant.PayMethodTypeEnum;
import com.jinlia.show.modules.base.constant.i.IBaseEnum;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * 付款单
 */
@Data
@TableName(value = "wxapp_pay_order", schema = DynamicSchemaConfig.schema_wxapp)
public class PayOrder extends BaseEntity {

    @TableId
    private Long id;
    /**
     * 用户id
     */
    private Long userId;

    /**
     * 来源单id:来源如果为会员卡充值为会员卡id
     */
    private Long payForId;

    private String payOrderNum;
    /**
     * 来源单类型 :见 PayForTypeEnum
     */
    private Integer payForType;
    @TableField(exist = false)
    private String payForTypeName;
    public void setPayForType(Integer payForType) {
        this.payForType = payForType;
        this.payForTypeName = IBaseEnum.getLabelByValue(payForType, PayForTypeEnum.class);
    }

    /**
     * 来源订单备注(充值活动)
     */
    private Long rechargeId;
    /**
     * 支付单金额
     */
    private BigDecimal payAmount;
    /**
     * 已支付金额
     */
    private BigDecimal paidAmount;
    /**
     * 收款状态 0:已支付:见 OrderPayStatusEnum
     */
    private Integer payOrderStatus;
    @TableField(exist = false)
    private String payOrderStatusName;
    public void setPayOrderStatus(Integer payOrderStatus) {
        this.payOrderStatus = payOrderStatus;
        this.payOrderStatusName = IBaseEnum.getLabelByValue(payOrderStatus, OrderPayStatusEnum.class);
    }


    /**
     * 收款日期
     */
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd")
    @JsonDeserialize(using = LocalDateDeserializer.class)
    private LocalDate payDate;
    /**
     * 收款时间
     */
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonDeserialize(using = LocalDateDeserializer.class)
    private LocalDateTime payDateTime;
}
